<template>
  <div>
    <div class="logo">
      <img src="../assets/logo.png" alt="" />
      <p>爱储云</p>
    </div>
    <div class="download">
      <div class="download_div1" @click="open(1)">
        <img src="../assets/ios@2x.png" alt="" />
        <span>IOS下载</span>
      </div>
      <div class="download_div1" @click="open(2)">
        <img src="../assets/anzhuo@2x.png" alt="" />
        <span>安卓下载</span>
      </div>
    </div>
    <div class="weixin_tip" ref="weixinTip" v-if="flag" @click="weixinTip">
      <p>
        <img src="../assets/live_weixin.png" alt="微信打开" />
      </p>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      request_time: "", //时间戳
      sign: "", //token
      iosdown: "", //iOS
      anddown: "", //安卓
      clientHeight: "", //可视区的高度
      flag: false,
    };
  },
  created() {
    this.getLink();
  },
  methods: {
    getLink() {
      this.axios.post("htmlInterface/user/getsign").then((res) => {
        if (res.data.code == 200) {
          this.request_time = res.data.data.request_time;
          this.sign = res.data.data.sign;
          let formData = new FormData();
          formData.append("request_time", this.request_time);
          formData.append("sign", this.sign);
          this.setLink(formData);
        } else {
          Toast(res.data.msg);
        }
      });
    },

    setLink(formData) {
      this.axios
        .post("appInterface/user/getStaticData", formData)
        .then((res) => {
          if (res.data.code == 200) {
            this.iosdown = res.data.data.ios_down;
            this.anddown = res.data.data.and_down;
          } else {
            Toast(res.data.msg);
          }
        });
    },

    open(i) {
      // this.$refs.weixinTip.style.height=this.clientHeight
      let isWeixin = this.is_weixin();
      if (isWeixin) {
        this.flag = true;
      } else {
        if (i == 1) {
          location.href = this.iosdown;
        } else if (i == 2) {
          location.href = this.anddown;
        }
      }
    },
    //点击隐藏 is_weixin
    weixinTip() {
      this.flag = false;
    },

    is_weixin() {
      const ua = navigator.userAgent.toLowerCase();
      if (ua.match(/MicroMessenger/i) == "micromessenger") {
        return true;
      } else {
        return false;
      }
    },

    open1(msg) {
      this.$message({
        message: msg,
        type: "success",
        center: true,
        duration: 1500,
      });
    },
  },
};
</script>
<style lang="less" scoped>
.weixin_tip {
  // display: none;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  filter: alpha(opacity=80);
  height: 100%;
  width: 100%;
  z-index: 100;
}
.weixin_tip p {
  text-align: center;
  margin-top: 10%;
  padding: 0 5%;
}

.download {
  display: flex;
  width: 90%;
  justify-content: space-around;
  margin: 2rem auto;
  .download_div1 {
    width: 35%;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 1.2026667rem;
    background-color: #fff;
    border-radius: 0.933333rem;
    box-sizing: content-box;
    padding: 0.233333rem 0;
    img {
      width: 0.85rem;
      height: 1.026667rem;
    }
    span {
      font-size: 0.5rem;
      padding-top: 0.2555555rem;
      padding-left: 0.4rem;
      font-weight: 550;
      color: #b79470;
    }
  }
}
.logo {
  img {
    width: 6.133333rem;
    height: 6.133333rem;
    margin: 8rem auto 0;
  }
  p {
    font-size: 1rem;
    margin: 0.533333rem 0;
    color: #fff;
  }
}
// async ()=>{
//   try {
//     await this.getVerifyInfo()
//   } catch (error) {
//     this.open1(error);
//   }
// }
// 统一处理axios请求
// async getHistoryData (data) {
//   try {
//     let res = await axios.get('/api/survey/list/', {
//       params: data
//     })
//     this.tableData = res.data.result
//     this.totalData = res.data.count
//   } catch (err) {
//     console.log(err)
//     alert('请求出错！')
//   }
// },
</style>
